package culton.android;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ConfigurationActivity extends Activity {

	private EditText trackerNumber;
	private Button save;	
    private SharedPreferences settings;

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.configuration);
        
        //Get number saved
        settings = getSharedPreferences("CultOnPreferences", MODE_PRIVATE);
        trackerNumber = (EditText) findViewById(R.id.trackerNumber);
        trackerNumber.setText(null);
        trackerNumber.setText(settings.getString("tracker", "none"));
        
        save = (Button) findViewById(R.id.save);
        save.setOnClickListener(new OnClickListener() {
            
        	public void onClick(View v) {
                String tracker = trackerNumber.getText().toString();
                
                //Updating value
                SharedPreferences.Editor editor = settings.edit();
                editor.putString("tracker", tracker);
                editor.commit();             
        		
        		startActivity (new Intent(getApplicationContext(), CultOnHome.class));
            }
        });
    }
}
